﻿@using PagedList.Mvc
@model PagedList.IPagedList<CubicFWNet.Data.ViewModal.InventoryChangeApplyView>
@{
    ViewBag.Title = "转库存申请";
}
<section class="content-header">
    <h1>
        转库存申请
    </h1>
    <ol class="breadcrumb">
        <li><a href="javascript:void(0);"><i class="fa fa-dashboard"></i>@Resources.Global.PageTitle</a></li>
        <li><a href="@Url.Action("Index","Home")">首页</a></li>
        <li class="active">转库存申请</li>
    </ol>
</section>
<section class="content">
    <div class="form-horizontal">
        <div class="box box-solid">
            <div class="box-nav clearfix">
                <div class="col-sm-12">
                    <form action="@Url.Action("InventoryChangeList", "StorageTable")" method="post">
                        <div class="col-sm-12">
                            <div class="form-group col-sm-4">
                                <label class="col-sm-4 control-label no-padding-right" for=""> 开始时间 </label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control datepicker" id="Start" name="Start" value="@ViewBag.Start" />
                                </div>
                            </div>
                            <div class="form-group col-sm-4">
                                <label class="col-sm-4 control-label no-padding-right" for=""> 截至时间 </label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control datepicker" id="End" name="End" value="@ViewBag.End" />
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-12">
                            <div class="form-group col-sm-4">
                                <label class="col-sm-4 control-label no-padding-right" for="">产品名称</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" id="Name" name="Name" value="@ViewBag.Name" />
                                </div>
                            </div>
                            <div class="form-group col-sm-4">
                                <div class="col-sm-offset-4">
                                    <div class="col-sm-8">
                                        <button type="submit" class="btn btn-primary">查询</button>
                                        <a class="btn btn-default" onclick="javascript: window.location.reload();" title="刷新"><span class="glyphicon glyphicon-refresh"></span></a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="box-body">
                <table class="footable table table-stripped table-bordered table-hover" id="footable" data-page-size="20" data-filter=#filter>
                    <thead>
                        <tr>
                            <th data-sort-ignore="true">
                                订单号
                            </th>
                            <th data-sort-ignore="true">
                                产品名称
                            </th>
                            <th data-sort-ignore="true">
                                数量
                            </th>
                            <th data-hide="phone,tablet" data-sort-ignore="true">
                                申请人
                            </th>
                            <th data-hide="phone,tablet" data-sort-ignore="true">
                                申请时间
                            </th>
                            <th data-hide="phone,tablet" data-sort-ignore="true">
                                状态
                            </th>
                            <th data-hide="phone,tablet" data-sort-ignore="true">
                                操作
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @if (null != Model)
                        {
                            foreach (var item in Model)
                            {
                                <tr>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.Number)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.ProductName)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.ApplyAmount)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.ApplyUserName)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.ApplyTime)
                                    </td>
                                    <td>
                                        @if (item.Status == 1)
                                        {
                                            <span>已完成</span>
                                        }
                                        else
                                        {
                                            <span>等待处理</span>
                                        }
                                    </td>
                                    <td>
                                        @if (item.Status == -1)
                                        {
                                            <span class="btn btn-primary btn-xs" onclick="FinishApply('@item.Id')">完 成</span>
                                        }

                                    </td>
                                </tr>
                            }
                        }
                    </tbody>
                    <tfoot>
                        <tr>
                            <td colspan="7">
                                每页 @Model.PageSize 条记录，共 @Model.PageCount 页，当前第 @Model.PageNumber 页
                                @Html.PagedListPager(Model, page => Url.Action("InventoryChangeApplyList", new { page }))
                            </td>
                        </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    </div>
</section>
<!--查询对话框-->
<div class="modal" id="" style="display: none">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">查询</h4>
            </div>

        </div>
    </div>
</div>
@section Scripts {
    <script>
        $(document).ready(function () {
            $('#footable').footable();
        });

        //function Select() {
        //    $('#queryDlg').modal();
        //}

        //完成转库存
        function FinishApply(id) {

            top.layer.confirm("确定已完成转库存吗？", {
                icon: "fa-exclamation-circle",
                title: "系统提示",
                btn: ['确认', '取消'],
                btnclass: ['btn btn-primary', 'btn btn-danger'],
            }, function () {
                $.ajax({
                    url: "/StorageTable/FinishApply",
                    type: "Post",
                    data: { id: id },
                    dataType: "json",
                    async: false,
                    success: function (data) {
                        location.reload();
                    }
                });
            }, function () {

            });
        }
    </script>
}